<template>
  <Card title="直播权限管理">
    <Table border stripe ref="selection" size="small" :columns="columns" :data="nowData">
      <template slot-scope="{ row, index }" slot="action">
        <Button v-if="row.cuUserMeeting == 0" type="primary" size="small" style="margin-right: 5px" @click="update(row.cuUserId,1)">赋予</Button>
        <Button v-if="row.cuUserMeeting == 1" type="error" size="small" @click="update(row.cuUserId,0)">取消</Button>
      </template>
    </Table>
    <Page :total="dataCount" :page-size="bo.size" @on-change="changepage" @on-page-size-change="_nowPageSize"
          show-total show-sizer show-elevator/>
  </Card>
</template>

<script>
export default {
  name: "user_update_meeting",
  data(){
    return{
      updateBo:{
        cuUserId:null,
        cuUserMeeting:null,
        cuUserIsLive:null,
      },
      dataCount:0,
      bo:{
        current:1,
        size:10,
        cuUsername:"",
      },
      columns:[
        {
          title: '序号',
          key: 'cuUserId'
        },
        {
          title: '昵称',
          key: 'cuUsername'
        },
        {
          title: '操作',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      nowData:[]
    }
  },
  methods:{
    _nowPageSize(index){
      // 实时获取当前需要显示的条数
      this.bo.size = index
    },
    changepage(index){
      this.bo.current = index;
      this.query()
    },
    update(cuUserId,num){
      this.updateBo.cuUserId = cuUserId;
      this.updateBo.cuUserMeeting = num;
      this.$axios_supermall.post("/user/updateIsLive",this.updateBo).then(resp=>{
        if (resp.data.code == 0){
          this.$Message.success("处理成功");
          this.query();
        }
      });
    },
    query(){
      this.$axios_supermall.post("/user/IsLiveQuery",this.bo).then(resp =>{
        if (resp.data.code == 0){
          this.nowData = resp.data.data.records;
          this.bo.current = resp.data.data.current;
          this.bo.size = resp.data.data.size;
          this.dataCount = resp.data.data.total;

        }
      })
    }
  },mounted() {
    this.query();
  }
}
</script>

<style scoped>

</style>
